<!DOCTYPE html>
<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>登录</title>
    <script src="js/jquery-3.5.1.min.js"></script>
    <link href="layui-v2.6.4/layui/css/layui.css" rel="stylesheet" type="text/css"/>
    <link href="layui-v2.6.4/layui/css/modules/code.css" rel="stylesheet" type="text/css"/>
    <script charset="utf-8" src="layui-v2.6.4/layui/layui.js" type="text/javascript"></script>
    <script>
        layui.use('element', function () {
            var element = layui.element;
        });

        function toSendEmil() {
            $("#btn_send").attr("disabled", "disabled");
            var submitButtonText = "重发";
            var second = 60;
            var intervalObj = setInterval(function () {
                $("#btn_send").text("(" + second + ")");
                if (second == 0) {
                    $("#btn_send").text(submitButtonText);
                    $("#btn_send").removeAttr("disabled");
                    clearInterval(intervalObj);
                }
                second--;
            }, 1000);
            $.ajax({
                url: "/sendAdminEmil"
                , type: 'get'
                , async: true
                , data: {
                    emil: $("#emil").val()
                }
                , success: function (res) {
                    if (res === '0') {
                        $("#msg").html("邮件发送不成功，请重试");
                    } else {
                        $("#msg").html(res);
                    }
                }
            });
        }


        function shensucheck(){
            var result=false;
            $.ajax({
                url:"/shensucheck"
                ,type:'post'
                ,async: false
                ,data: {
                    phone:$("#phoneId").val()
                    ,password:$("#passwordId").val()
                }
                ,success:function (res) {
                    if (res==0){
                        result=true;
                    }else if(res==1) {
                        layer.msg("账号密码不正确, 请重试")
                        result=false;
                    }else{
                        layer.msg("当前账号未被停封!")
                        result=false;
                    }
                }
            })
            return result;
        }

        function resigned() {
            var isok = false;
            $.ajax({
                url: "/isUserRes"
                , type: 'get'
                , async: false
                , data: {
                    Num: $("#Phone").val()
                    , Pwd: $("#pwd").val()
                    , Pwd1: $("#pwd1").val()
                    , Emil: $("#emil").val()
                    , emilRes: $("#emilRes").val()
                }
                , success: function (res) {
                    $("#msg").html(res);
                    if (res === '1') {
                        isok = true;
                    }
                }
            });

            if (isok) {
                return true;
            } else {
                return false;
            }
        }

        function zhaohuicheck(){
            var restult=false;
            $.ajax({
                url:"/user/zhaohuicheck"
                ,type:'post'
                ,async: false
                ,data: {
                    phone:$("#phoneId").val()
                    ,email:$("#emailId").val()
                }
                ,success:function (res) {
                    if (res==0){
                        layer.msg("账号或者邮箱错误!!!")
                        return false;
                    }else {
                        var pwd1=$("#newpwdId1").val();
                        var pwd2=$("#newpwdId2").val()
                        if (pwd1==pwd2){
                            restult=true;
                        }else {
                            layer.msg("两次密码输入不一致!!!");
                            restult=false;
                        }
                    }
                }
            })
            return restult;
        }

        function toshensu(){
            layer.open({
                type: 1,
                title: false,
                closeBtn: 0,
                shadeClose: true,
                skin: 'yourclass',
                content: '<div>\n' +
                    '\t\t<form class="layui-form" action="/shensu" method="post" onsubmit="return shensucheck()">\n' +
                    '\t\t\t<span th:text="${msg}"></span>' +
                    '\t\t\t<div class="layui-form-item">\n' +
                    '\t\t\t    <label class="layui-form-label">申诉账号</label>\n' +
                    '\t\t\t    <div class="layui-input-inline">\n' +
                    '\t\t\t      <input type="text" name="phone" id="phoneId" required  lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input">\n' +
                    '\t\t\t    </div>\n' +
                    '\t\t\t</div>\n' +
                    '\t\t\t  \n' +
                    '\t\t\t <div class="layui-form-item">\n' +
                    '\t\t\t    <label class="layui-form-label">申诉密码</label>\n' +
                    '\t\t\t    <div class="layui-input-inline">\n' +
                    '\t\t\t      <input type="password" name="password" id="passwordId" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">\n' +
                    '\t\t\t    </div>\n' +
                    '\t  \t\t</div>\n' +
                    '\t  \t\t\n' +
                    '\t  \t\t<div class="layui-form-item layui-form-text">\n' +
                    '\t\t\t    <label class="layui-form-label">申诉理由</label>\n' +
                    '\t\t\t    <div class="layui-input-block">\n' +
                    '\t\t\t      <textarea name="content" placeholder="请输入内容" class="layui-textarea" style="width: 400px;"></textarea>\n' +
                    '\t\t\t    </div>\n' +
                    '\t  \t\t</div>\n' +
                    '\t  \t\t\n' +
                    '\t  \t\t<div class="layui-form-item">\n' +
                    '\t\t\t    <div class="layui-input-block">\n' +
                    '\t\t\t      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>\n' +
                    '\t\t\t      <button type="reset" class="layui-btn layui-btn-primary">重置</button>\n' +
                    '\t\t\t    </div>\n' +
                    '\t\t\t</div>\n' +
                    '\t\t</form>\n' +
                    '\t\t</div>'
            })
        }

        //忘记密码
        function toForgetPaw(){
            layer.open({
                type: 1,
                title: false,
                closeBtn: 0,
                shadeClose: true,
                skin: 'yourclass',
                content: '<div>\n' +
                    '\t\t<form class="layui-form" action="/user/zhaohui" method="post" onsubmit="return zhaohuicheck()">\n' +
                    '\t\t\t<span th:text="${msg}"></span>' +
                    '\t\t\t<div class="layui-form-item">\n' +
                    '\t\t\t    <label class="layui-form-label">账号</label>\n' +
                    '\t\t\t    <div class="layui-input-inline">\n' +
                    '\t\t\t      <input type="text" name="phone" id="phoneId" required  lay-verify="required" placeholder="请输入忘记账号" autocomplete="off" class="layui-input">\n' +
                    '\t\t\t    </div>\n' +
                    '\t\t\t</div>\n' +
                    '\t\t\t  \n' +
                    '\t\t\t<div class="layui-form-item">\n' +
                    '\t\t\t    <label class="layui-form-label">验证邮箱</label>\n' +
                    '\t\t\t    <div class="layui-input-inline">\n' +
                    '\t\t\t      <input type="text" name="email" id="emailId" required  lay-verify="required" placeholder="请输入验证邮箱" autocomplete="off" class="layui-input">\n' +
                    '\t\t\t    </div>\n' +
                    '\t\t\t</div>\n' +
                    '\t\t\t<div class="layui-form-item">\n' +
                    '\t\t\t    <label class="layui-form-label">新密码</label>\n' +
                    '\t\t\t    <div class="layui-input-inline">\n' +
                    '\t\t\t      <input type="password" name="newpwd1" id="newpwdId1" required  lay-verify="required" placeholder="请输入验证邮箱" autocomplete="off" class="layui-input">\n' +
                    '\t\t\t    </div>\n' +
                    '\t\t\t</div>\n' +
                    '\t\t\t<div class="layui-form-item">\n' +
                    '\t\t\t    <label class="layui-form-label">确认新密码</label>\n' +
                    '\t\t\t    <div class="layui-input-inline">\n' +
                    '\t\t\t      <input type="password" name="newpwd2" id="newpwdId2" required  lay-verify="required" placeholder="请输入验证邮箱" autocomplete="off" class="layui-input">\n' +
                    '\t\t\t    </div>\n' +
                    '\t\t\t</div>\n' +

                    '\t  \t\t\n' +
                    '\t  \t\t<div class="layui-form-item">\n' +
                    '\t\t\t    <div class="layui-input-block">\n' +
                    '\t\t\t      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>\n' +
                    '\t\t\t    </div>\n' +
                    '\t\t\t</div>\n' +
                    '\t\t</form>\n' +
                    '\t\t</div>'
            })
        }

        function toReSignin() {
            layer.open({
                type: 1,
                title: false,
                closeBtn: 0,
                shadeClose: true,
                skin: 'yourclass',
                content: '<div>\n' +
                    '\t\t\t    <span id="msg">&nbsp;</span>' +
                    '\t\t\t    <form class="layui-form" action="/userResiger" method="post" onsubmit="return resigned()">\n' +
                    '\t\t\t        <div class="layui-form-item" style="margin: 20px;">\n' +
                    '\t\t\t            <label class="layui-form-label">手机号</label>\n' +
                    '\t\t\t            <div class="layui-input-block">\n' +
                    '\t\t\t                <input class="layui-input" type="text" id="phone" name="Phone" required lay-verify="required"\n' +
                    '\t\t\t                       placeholder="请输入手机号" autocomplete="off">\n' +
                    '\t\t\t            </div>\n' +
                    '\t\t\t        </div>\n' +
                    '\t\t\t        <div class="layui-form-item" style="margin: 20px;">\n' +
                    '\t\t\t            <label class="layui-form-label">密码</label>\n' +
                    '\t\t\t            <div class="layui-input-block">\n' +
                    '\t\t\t                <input class="layui-input" type="password" id="pwd" name="Pwd" required lay-verify="required"\n' +
                    '\t\t\t                       placeholder="请输入密码" autocomplete="off">\n' +
                    '\t\t\t            </div>\n' +
                    '\t\t\t        </div>\n' +
                    '\t\t\t        <div class="layui-form-item" style="margin: 20px;">\n' +
                    '\t\t\t            <label class="layui-form-label">密码</label>\n' +
                    '\t\t\t            <div class="layui-input-block">\n' +
                    '\t\t\t                <input class="layui-input" type="password" id="pwd1" name="Pwd1" required lay-verify="required"\n' +
                    '\t\t\t                       placeholder="请再次输入密码" autocomplete="off">\n' +
                    '\t\t\t            </div>\n' +
                    '\t\t\t        </div>\n' +
                    '\t\t\t        <div class="layui-form-item" style="margin: 20px;">\n' +
                    '\t\t\t            <label class="layui-form-label">邮箱</label>\n' +
                    '\t\t\t            <div class="layui-input-block">\n' +
                    '\t\t\t                <input class="layui-input" type="text"  name="Emil" required lay-verify="required"\n' +
                    '\t\t\t                     id="emil" placeholder="请输入邮箱" autocomplete="off">\n' +
                    '\t\t\t                <button id="btn_send" onclick="toSendEmil()">发送</button>\n' +
                    '\t\t\t            </div>\n' +
                    '\t\t\t        </div>\n' +
                    '\t\t\t        <div class="layui-form-item" style="margin: 20px;">\n' +
                    '\t\t\t            <label class="layui-form-label">验证码</label>\n' +
                    '\t\t\t            <div class="layui-input-block">\n' +
                    '\t\t\t                <input class="layui-input" type="text"  name="emilRes" required lay-verify="required"\n' +
                    '\t\t\t                     id="emilRes" placeholder="请输入验证码" autocomplete="off">\n' +
                    '\t\t\t            </div>\n' +
                    '\t\t\t        </div>\n' +
                    '\t\t\t        <div class="layui-form-item" style="margin: 20px;">\n' +
                    '\t\t\t            <div class="layui-input-block">\n' +
                    '\t\t\t                <input class="layui-btn" type="submit" value="提交">\n' +
                    '\t\t\t            </div>\n' +
                    '\t\t\t        </div>\n' +
                    '\t\t\t    </form>\n' +
                    '\t\t\t</div>'
            });
        }
    </script>
</head>
<body background="img/bg/user_bg.jpg" style="background-size: 100%;">
<div class="layui-row">
    <div class="layui-col-md4 layui-col-md-offset4 layui-row"
         style="backdrop-filter: blur(35px);margin-top: 100px;height: 350px;padding-top: 75px;padding-right: 78px;color: white;border: 1px solid ;border-radius: 25px;">
        <h1 style="text-align: center;">欢迎您的登录</h1>
        <span style="color: red;text-align: center;" th:text="${msg}">&nbsp;</span>
        <form action="/userLogin" class="layui-form" method="post">
            <div class="layui-form-item" style="margin: 20px;">
                <label class="layui-form-label">账号</label>
                <div class="layui-input-block">
                    <input autocomplete="off" class="layui-input" lay-verify="required" name="userNum"
                           placeholder="请输入账号"
                           required type="text">
                </div>
            </div>
            <div class="layui-form-item" style="margin: 20px;">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input autocomplete="off" class="layui-input" lay-verify="required" name="userPwd"
                           placeholder="请输入密码"
                           required type="password">
                </div>
            </div>
            <div class="layui-form-item" style="margin: 20px;">
                <div class="layui-input-block layui-row">
                    <button class="layui-btn layui-col-md5 layui-btn-warm" lay-filter="formDemo" lay-submit>登录</button>
                    <button class="layui-btn layui-col-md5 layui-col-md-offset2 layui-btn-danger"
                            onclick="toReSignin()">注册
                    </button>
                </div>
            </div>
        </form>
        <span class="layui-breadcrumb" lay-separator="|" style="margin-left: 60px">
            <a onclick="toForgetPaw()" style="color:#44398a;">忘记密码</a>
            <a onclick="toshensu()" style="color:#44398a;">账号申诉</a>
            <a href="/toadminlogin" style="color:#44398a;">管理员登录</a>
            <a href="/" style="color:#44398a;">主站</a>
        </span>

    </div>
</div>
</body>
</html>